
/**  File: enemy.h
 *   Author: Jaideep Balekar
 *           Department of Computer Science
 *           Texas A&M University
 *           315 - Programming Studio
 * Due Date: December 6th, 2009 @ 11:59
 * Contents: derived from character class. This class represents the enemies, it sets the enemy state paints the enemy on to the GUI,
			 directs the enemy movements (by detecting the walls). 	
*/


#ifndef ENEMY_H
#define ENEMY_H

#include "character.h"
#include "player.h"
#include "mapbuilder.h"
#include "state.h"
#include "fsm.h"

#include <QList>
#include <QString>
#include <QTime>
#include <math.h>

static QTime SUPER_PLAYER_TIME;
static QList<int> GO_INIT;

class Enemy : public Character {
    private:
        MapBuilder* ml;

        static const int INIT_STATE = 0;
        static const int PLAY_STATE = 1;
        static const int FOLLOW_STATE = 2;
        static const int DYING_STATE = 3;
        static const int ZOMBIE_STATE = 4;
        static const int DEAD_STATE = 5;
        static const int DYING_STATE_LIMIT = 9000;
        static const int ZOMBIE_STATE_LIMIT = 1000;
        static const int DEAD_TIMEOUT = 5000;

        int initX;
        int initY;

        QString INIT; 
        QString PLAY; 
        QString FOLLOW; 
        QString DYING; 
        QString ZOMBIE; 
        QString DEAD; 

        bool isWallPresent(int);
        void removeOddOption(QList<int> *);

        QPixmap *spritesImage;

        int myId;
        bool move;

        void dyingCheck();
        void playSound();
        QTime deadTime;
        bool doneInit;

    public:
        Enemy(int, int, int, bool, MapBuilder*, QString);
		FSM fsm;
        bool watch;
        static const int ID_ENEMY  = 10;
        int getType() const;
        virtual int type() const;
        void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
        void update();

        void setAndAddStates();
        void killed();
        static void superPlayer();
        static void resetEnemyCount();
};

#endif // ENEMY_H
